package net.pascalalma.hadoop;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.util.Tool;

public class Dictionary extends Configuration implements Tool{

	public Configuration getConf() {
		// TODO 자동 생성된 메소드 스텁
		return this;
	}

	public void setConf(Configuration arg0) {
		// TODO 자동 생성된 메소드 스텁
		
	}

	public int run(String[] arg0) throws Exception {
		// TODO 자동 생성된 메소드 스텁
		return 0;
	}

	
    public static void main(String[] args) throws Exception{
		
		Configuration conf= new Configuration();
		
		Job job=Job.getInstance();
		job.setJarByClass(Dictionary.class);
		job.setJobName(Dictionary.class.getName());
		job.setMapperClass(WordMapper.class);
		job.setCombinerClass(AllTranslationsReducer.class);
		job.setReducerClass(AllTranslationsReducer.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);
		job.setMapOutputKeyClass(Text.class);
		job.setMapOutputValueClass(Text.class);
		job.setInputFormatClass(KeyValueTextInputFormat.class);
		job.setOutputFormatClass(TextOutputFormat.class);
		FileInputFormat.addInputPath(job, new Path(args[0]));
		FileOutputFormat.setOutputPath(job, new Path(args[1]));
		boolean result = job.waitForCompletion(true);
		System.exit(result ? 0 : 1);
		
		
	}
}
